<?

	include("inc/config.inc.php");


	$daysToWarn = 2; // Warn about approvals older than this many days

	$result = mysqli_query($conn, "SELECT user,email FROM users WHERE (role='hr' OR role='manager') AND deleted=0 AND prestaged=0");

	if (mysqli_num_rows($result) > 0)
	{
		while ($manager = mysqli_fetch_array($result))
		{

			$_SESSION[user] = $manager[user];

	                $approvalsWaiting = getOldWaitingApprovalsCount($daysToWarn);
	                if ($approvalsWaiting > 0)
	                {

				 // Email manager
			         niceMail($manager[email], 'Holiday requests require your approval', "There are currently $approvalsWaiting holiday requests in the system that still require your approval.\n\r\n\rPlease visit " . $config[url] . " to accept or reject the requests as soon as possible.");
                	}

		}

	}

	else
	{
		echo "ERROR: No managers found!";
	}

	mysqli_free_result($result);

?>
